package org.example.springioc.controller;

import jakarta.annotation.Resource;
import org.example.springioc.model.UserObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:38917
 * Date:2025/4/21
 * Time:17:43
 */
@Controller
public class UserController {

    //优先根据名称匹配
    //其次根据类型匹配
    @Resource(name = "getUserObject4")
    @Qualifier("getUserObject3")
    @Autowired
    private UserObject getUserObject1;
    //办法一:@Primary+@Autowired
    //办法二:@Qualifier()+@Autowired
    //办法三:@Resource()

    public void demo() {
        System.out.println("Hello UserController");
        System.out.println(getUserObject1);
    }
    //优先级
    //Resource > Qualifier > Primary > Autowired
}
